<template>
	<view>
		<!-- <cu-custom :bgColor="'bg-'+ theme.themeColor" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">分销中心</block>
		</cu-custom> -->
		<view class="header-con">
			<view class="header-containe">
				<view class="header-conLeft" @tap="BackPage" v-if="isNotBack">
					<uni-icons type="back" size="25" color="#000"></uni-icons>
				</view>
				<view class="header-conLeft" @tap="GoHome" v-else-if="!isNotBack">
					<text class="cuIcon-home">首页</text>
				</view>
				<view class="header-conBox">
					<view class="header-conImg">
						<image class="imgStyle" :src="userInfo.avatarUrl || defaultPic" mode=""></image>
					</view>
					<view class="header-conText">
						<text v-if="userInfo.nickName">{{userInfo.nickName}}</text>
						<text style="margin-top: 5px;">推荐人:XXX</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="distribution-con" style="padding-top: 21px;">
			<view class="distribution-box">
				<view class="distribution-ul">
					<view class="distribution-li">
						<text>成功提现(元)</text>
						<text class="textColor">{{distributionUser.totalAmount ? distributionUser.totalAmount: 0.00}}</text>
					</view>
					<view class="distribution-li">
						<text>可提现(元)</text>
						<text class="textColor">{{distributionUser.totalAmount-distributionUser.frozenAmount}}</text>
					</view>
				</view>
				<view class="distribution-btn" @tap="withdrawal">立即提现</view>
			</view>
		</view>
		
		<view class="distribution-fx">
			<view class="distribution-fxUl">
				<view class="distribution-fxli" @tap="toRouter"> 
						<view class="imgStyles"></view>
						<view class="distribution-fxliText">
							<text>
								分销佣金
							</text>
							<text class="textColor">0.00元</text>
						</view>
				</view>
				
				<view class="distribution-fxli" @tap="toRouter('/pages/distribution/distribution-order/order-list/index')">
						<view class="imgStyles imgStyles2"></view>
						<view class="distribution-fxliText">
							<text>
								分销订单
							</text>
							<text class="textColor">0笔</text>
						</view>
				</view>
				
				<view class="distribution-fxli" @tap="toRouter('/pages/user-withdrawal/withdrawal-record/index')" style="padding-bottom: 0;">
						<view class="imgStyles imgStyles3"></view>
						<view class="distribution-fxliText">
							<text>
								提现记录
							</text>
							<text class="textColor">0笔</text>
						</view>
				</view>
				
				<view class="distribution-fxli" @tap="toRouter('/pages/distribution/distribution-team/index')" style="padding-bottom: 0;">
						<view class="imgStyles imgStyles4"></view>
						<view class="distribution-fxliText">
							<text>
								我的团队
							</text>
							<text class="textColor">0人</text>
						</view>
				</view>
			</view>
		</view>
		
		<!-- <view :class="'bg-'+theme.themeColor">
			<view class="flex padding">
				<view v-if="userInfo.avatarUrl" class="cu-avatar round xl head flex"
					:style="'background-image:url(' + userInfo.avatarUrl + ')'">
				</view>
				<view class="padding-sm">
					<view v-if="userInfo.nickName">
						{{userInfo.nickName}}
					</view>
					<view v-if="userInfo.phone" class="padding-tb-sm">
						{{userInfo.phone}}
					</view>
				</view>
			</view>
			<view class="grid no-border col-3  flex justify-center align-center">
				<view class="content text-center">
					<view class="text-xl text-price">
						{{distributionUser.frozenAmount ? distributionUser.frozenAmount: 0.00}}
					</view>
					<view class="text-sm">冻结中佣金</view>
				</view>
				<view class="content text-center">
					<view class="text-xl text-price">
						{{distributionUser.totalWithdrawal ? distributionUser.totalWithdrawal: 0.00}}
					</view>
					<view class="text-sm">累计提现</view>
				</view>
				<view class="content text-center">
					<view class="text-xl text-price">
						{{distributionUser.totalAmount ? distributionUser.totalAmount: 0.00}}
					</view>
					<view class="text-sm">累计获得佣金</view>
				</view>
			</view>
		</view> -->
		<!-- <view class="margin-sm radius bg-white">
			<view class="cu-list menu solid-bottom">
				<view class="cu-item ">
					<view class="content padding-tb-sm">
						<view>
							<text class="cuIcon-recharge text-blue margin-right-xs"></text> 可提现金额
						</view>
						<view class=" text-xxl padding">
							<text
								class="text-price text-red">{{distributionUser.totalAmount-distributionUser.frozenAmount}}</text>
						</view>
					</view>
					<view class="action">
						<button class="cu-btn bg-red margin-tb-sm lg round" @tap="withdrawal">提现</button>
					</view>
				</view>
			</view>
			<view class="cu-list grid no-border col-4">
				<view class="cu-item">
					<navigator class="content" hover-class="none" url="/pages/distribution/distribution-card/index">
						<view class="cuIcon-qr_code" :class="'text-'+ theme.themeColor"></view>
						<view class="text-grey">推广名片</view>
					</navigator>
				</view>
				<view class="cu-item">
					<navigator class="content" hover-class="none"
						url="/pages/user-withdrawal/withdrawal-record/index">
						<view class="cuIcon-vipcard" :class="'text-'+ theme.themeColor"></view>
						<view class="text-grey">提现记录</view>
					</navigator>
				</view>
				<view class="cu-item">
					<navigator class="content" hover-class="none"
						url="/pages/distribution/distribution-order/order-list/index">
						<view class="cuIcon-form" :class="'text-'+ theme.themeColor"></view>
						<view class="text-grey">分销订单</view>
					</navigator>
				</view>
				<view class="cu-item">
					<navigator class="content" hover-class="none" url="/pages/distribution/distribution-team/index">
						<view class="cuIcon-friend" :class="'text-'+ theme.themeColor"></view>
						<view class="text-grey">我的团队</view>
					</navigator>
				</view>
			</view>
		</view> -->

	</view>

</template>

<script>
	import {
		getObj
	} from '@/api/distributionuser.js';
	export default {
		data() {
			return {
				theme: getApp().globalData.theme,
				userInfo: this.$store.state.user.userInfo,
				distributionUser: {},
				isNotBack: true,
				defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
			}
		},
		onLoad() {
			this.getData();
		},
		mounted: function() {
			let pages = getCurrentPages()
			/**
			 * 判断是否能返回
			 */
			if (pages.length <= 1 || pages[pages.length - 1].route == 'pages/login/index') {
				this.isNotBack = false
			} else {
				this.isNotBack = true
			}
		},
		methods: {
			toRouter(url){
				uni.navigateTo({
					url:url
				})
			},
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
			},
			getData() {
				getObj({}).then(res => {
					this.distributionUser = res.data
				});
			},
			withdrawal() {
				uni.navigateTo({
					url: "/pages/user-withdrawal/withdrawal-apply/index"
				})
			},
			/**
			 * 跳转首页
			 */
			GoHome() {
				uni.switchTab({
					url: '/pages/home/index'
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	page{
		background-color: #f8f8f8;
	}
	.cuIcon-home{
		color: #000;
		font-weight: 400;
		font-size: 18px;
	}
	.header-conBox{
		display: flex;
		align-items: center;
		margin-top: 20rpx;
	}
	.header-con{
		background: url('#{$global-url-prefix}bg.png') no-repeat;
		padding-top: 60rpx;
		background-size: cover;
		height: 367px;
		.header-containe{
			width: 703.13rpx;
			margin: 0 auto;
			
		}
		
	}
	.header-conText{
		display: flex;
		flex-direction: column;
		font-size: 24rpx;
		margin-left: 10px;
		color: #000;
	}
	.header-conImg .imgStyle{
		margin-top: 10px;
		margin-bottom: 15px;
		width: 97rpx;
		height: 97rpx;
		border: 2px solid #FFFFFF;
		box-shadow: 0rpx 8rpx 15rpx 0rpx rgba(0,0,0,0.35);
		border-radius: 50%;
	}
	.distribution-con{
		padding: 35rpx 80.23rpx;
		width: 703.13rpx;
		margin: 0 auto;
		background: url('#{$global-url-prefix}fxjx1.png') no-repeat;
		background-size: cover;
		margin-top: -381rpx;
		border-radius: 9px;
	}
	.distribution-ul{
		display: flex;
		justify-content: space-between;
		.distribution-li{
			display: flex;
			flex-direction: column;
			align-items: center;
			font-size: 26rpx;
			color:#8D8D8D ;
			.textColor{
				margin-top: 10px;
				color: #E6BDA0 !important;
			}
		}
	}
	.distribution-btn{
		width: 306rpx;
		height: 74rpx;
		background: #FED1B1;
		border-radius: 33rpx;
		margin: 45rpx auto 0;
		font-size: 26rpx;
		text-align: center;
		line-height: 74rpx;
	}
	.distribution-fx{
		padding: 66rpx 80.23rpx;
		width: 703.13rpx;
		margin: 0 auto;
		box-shadow: 0rpx 8rpx 15rpx 0rpx rgba(0,0,0,0.05);
		border-radius: 18rpx;
		background-color: #fff;
		margin-top: 11.72rpx;
	}
	.distribution-fxUl{
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		.distribution-fxli{
			display: flex;
			width: 50%;
			padding-bottom:62rpx;
			align-items: center;
			&:nth-child(even) {
			    justify-content: flex-end;
			}
			.imgStyles{
				width: 51.56rpx;
				height: 51.56rpx;
				background: url('#{$global-url-prefix}fxjb.png') no-repeat;
				background-size: cover;
			}
			.imgStyles2{
				background: url('#{$global-url-prefix}fxdd.png') no-repeat !important;
				background-size: cover !important;
			}
			.imgStyles3{
				background: url('#{$global-url-prefix}qb.png') no-repeat !important;
				background-size: cover !important;
			}
			.imgStyles4{
				background: url('#{$global-url-prefix}td.png') no-repeat !important;
				background-size: cover !important;
			}
			
			.distribution-fxliText{
				margin-left: 10px;
				display: flex;
				flex-direction: column;
				color: #000;
				.textColor{
					color: #7C7E82;
					margin-top: 3px;
				}
			}
		}
	}
</style>
